Back to Editorials CodeCraft β
  • Github
  • Instagram
< >

Attendance Register

TIME LIMIT = 1 SEC.

  • In a parallel universe, VBIT is located on Mars. And with every academic year, new students come in and seniors pass out (most of them). Now, all the faculty is busy with other important work, so the HoD of Avishkar block has asked you to prepare the attendance register of a section.
    The attendance register is always in the lexicographical order i.e. the Dictionary order. Given, N names of students, print the names in lexicographical order. Note that the names of the students do not exceed the size of 30. Also, note that Martian names are gibberish, and are not like Earthling names.
Input Output
First line will contain N , number of testcases.
Each of the following N lines contain the name of each student.
Print the names in lexicographical order.
Constraints
  • 1 ≤ N ≤ 1000
  • 2 ≤ Length of Name ≤ 30
Example Test Case
Input             Output
3
aa
ab
aaa
aa
aaa
ab
Solution

#include <iostream> #include <string> #include <set> #include <iterator> using namespace std; int main() { int n,i; cin>>n;//take number of names set<string> names; // stores names in sorted order. set<string>::iterator it; //iterates over each name in the set string temp; for(i=0;i<n;i++) { cin>>temp; //take in a name names.insert(temp); //put it into set } for(it=names.begin();it!=names.end();++it) cout<<*it<<endl;// while printing , the names will be in sorted order since we are using a set return 0; }
  • #1 Thieves
  • #2 The Queue of Doubts
  • #3 Summation of Primes
  • #4 Spacious Maximus
  • #5 Samosas
  • #6 Reasonably Sound
  • #7 Product of Digits
  • #8 Prime Usernames
  • #9 Path Shifter
  • #10 Keypad Count
  • #11 Even Vowels
  • #12 Encryption
  • #13 Decryption
  • #14 Canteen Accountant
  • #15 Attendance Register
  • #16 Amazing Year

Get in touch

  • executives@codingstudio.club
  • +91 9010342360
  • Vignana Bharthi Instute of Technology
    Aushapur, Ghatkesar, Hyderabad, Telengana - India

© coding.Studio();